package com.tencent.cloud.iov.util;

import android.content.Context;
import android.net.ConnectivityManager;
import android.net.NetworkInfo;

/**
 * @author vinsonhuang
 * @date 2018/6/7
 */
public class NetworkUtils {

    public static boolean isNetworkAvailable(Context context) {
        ConnectivityManager manager = (ConnectivityManager) context.getApplicationContext()
                .getSystemService(Context.CONNECTIVITY_SERVICE);
        if (null == manager) {
            return false;
        }
        NetworkInfo networkinfo = manager.getActiveNetworkInfo();
        if (null != networkinfo && networkinfo.isConnected() && networkinfo.isAvailable()) {
            return true;
        }
        return false;
    }
}
